package com.lzx.tease.controller.web;

import com.lzx.common.utils.R;
import com.lzx.tease.entity.Recommend;
import com.lzx.tease.service.RecommendService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 程序员星星
 * @date 2022/12/20
 * @Description
 */
@RestController
@RequestMapping("/tease/recommend/web")
public class WebRecommendController {
    @Resource
    private RecommendService recommendService;

    //获取反馈总数
    @GetMapping("/getRecommendTotal")
    public Integer getRecommendTotal() {
        return Math.toIntExact(recommendService.count());
    }

    //查询当前用户是否已经提交建议
    @GetMapping("/queryRecommendByUserId/{userId}")
    public R queryRecommendByUserId(@PathVariable int userId) {
        return recommendService.queryRecommendByUserId(userId);
    }

    //保存用户的建议
    @PostMapping("/saveRecommend")
    public R saveRecommend(@RequestBody Recommend recommend) {
        return recommendService.saveRecommend(recommend);
    }
}
